/*
 * @Author: cooper
 * @Date: 2025-03-30 21:35:19
 * @Wechat: cmd_develop
 * @Description:
 */
#ifndef BSP_TEMPUTURE
#define BSP_TEMPUTURE

#include "common.h"

extern QueueHandle_t temputure_work_queue;

void TEMPUTURE_UART_INIT(void);
void TEMPUTURE_TASK(void);
void TEMPUTURE_UART_DMA_TX(u16 size);
void temputure_cmd_queue_send(u8 code[3]);

#define temputure_DATA_SIZE 30

typedef struct
{
    u8 rx_data[temputure_DATA_SIZE]; /*接收数据缓冲区*/
    u16 rx_total;                    /*接收数据大小*/
    u8 tx_data[temputure_DATA_SIZE]; /*发送数据缓冲区*/
    u16 tx_total;                    /*发送总数据大小*/
} temputure_buffer;

extern temputure_buffer temputure_Buffer;

#define RX_temputure(x) temputure_Buffer.rx_data[x]
#define RX_temputure_TOTAL temputure_Buffer.rx_total
#define TX_temputure(x) temputure_Buffer.tx_data[x]
#define TX_temputure_TOTAL temputure_Buffer.tx_total

#define RX_temputure_BufClear()                      \
    do                                               \
    {                                                \
        for (u16 i = 0; i < RX_temputure_TOTAL; i++) \
        {                                            \
            RX_temputure(i) = 0;                     \
        }                                            \
        RX_temputure_TOTAL = 0;                      \
    } while (0)
#define TX_temputure_BufClear()                      \
    do                                               \
    {                                                \
        for (u16 i = 0; i < TX_temputure_TOTAL; i++) \
        {                                            \
            TX_temputure(i) = 0;                     \
        }                                            \
        TX_temputure_TOTAL = 0;                      \
    } while (0)

#endif
